<?php

class ModuleModel extends CActiveRecord
{
        public function tableName()
	{
		return '{{module}}';
	}

	/**
	 * Declares the validation rules.
	 * The rules state that username and password are required,
	 * and password needs to be authenticated.
	 */
	public function rules()
	{

	}
        
        public function get_menus(){
            $menus = self::model()->findAll('ismenu=:ismnu AND disabled=:disabled ORDER BY listorder DESC,moduleid DESC', array(':ismnu'=>1,':disabled'=>1));
            $return = "";
            foreach ($menus as $menu){
                $isHot = $menu->is_hot==1?"<em class='is_hot'></em>":"";
                $isNew = $menu->is_new==1?"<em class='is_new'></em>":"";
                $label = $menu->module_name.$isHot.$isNew;
                
                $return[] = array(
                   'label'=>$label, 'url'=>array('/front/module/index/', 'mid'=>$menu->moduleid) 
                );
            }
            return $return;
        }
        
        
        public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

}

